package edu.sctu.wulixia.month6.day20150628;

import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

/**
 * Created by user05 on 2015/6/28.
 */
public class GainData implements Runnable{
    Thread thread;
    public String line="";

    public void run(){

        try {
            System.out.println("程序在5秒后开始：");
            thread.sleep(5000);
//获取url数据
            try {
                URL url = new URL("http://api.ii.com.cn/goods/apprec");
                URLConnection urlConnection = url.openConnection();
                InputStream is = urlConnection.getInputStream();
                InputStreamReader isr = new InputStreamReader(is);
                BufferedReader br = new BufferedReader(isr);

                int count;
                char[] buffer = new char[is.available()];

                while ((count = br.read(buffer)) != -1){
                   line = new String(buffer,0,count);

                }

                SaveData.isSave(line);
                AnalyzeJson.isAnalyzeJson(line);

                br.close();
                isr.close();
                is.close();

//获取序列化，反序列化结果

                JsonAppbean jsonAppbean = new JsonAppbean();
                SerializableJson sj = new SerializableJson();
                sj.isSerializableJson(jsonAppbean);
                sj.isAntiSerializableJson();


//获取判断商品价格类的结果

                GoodsSize goodsSize = new GoodsSize();
                goodsSize.isJudgePrice(jsonAppbean);

            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }

        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }

}
